package test

import (
	"log"
	"server/lib/mysqldb"
	"server/lib/redis"
)

func Test() string {
	c := redis.Get()
	defer c.Close()
	i, err := c.Get("p")
	if err != nil {
		log.Println(err)
		return "err"
	}
	return i
}

func Testdb() (map[int]map[string]string, error) {
	db := mysqldb.GetConnect()
	// return db.Execute("select id as ids, wxname, headerpic from tp_wxuser")
	ret := db.SetTable("i_goods_class").OrderBy("id").FindOne()
	return ret, nil
}

func Testdb2() []map[string]string {
	sdb, _ := mysqldb.GetConnect().IBagin()
	rows, _ := sdb.IExecute("select name from i_goods_class order by id")
	// i, _ := sdb.Insert("INSERT INTO tp_express VALUES (NULL, ?, ?)", "sad", "test")
	// fmt.Fprintln(res, i)
	// s, _ := sdb.Get().Prepare("INSERT INTO tp_express VALUES (NULL, ?, ?)")
	// i, _ := s.Exec("sad", "test2")
	// j, _ := i.LastInsertId()

	// var m []map[string]interface{}
	// for i := 0; i < 20; i++ {
	//  s := make(map[string]interface{})
	//  s["name"] = "sad"
	//  s["bm"] = "test1"
	//  m = append(m, s)
	// }
	// k, _ := sdb.Insertmanay("tp_express", m...)
	// fmt.Println(k)

	sdb.Commit()
	// log.Println(err)
	return rows
}
